//
//  ZYCCircleFriendsColletionCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/23.
//

#import "ZYCCircleFriendsColletionCell.h"
#import "ZYCCycleFriendDetailModel.h"
#import "ZYCCycleFriendsDetailBottomView.h"

@interface ZYCCircleFriendsColletionCell()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) ZYCCycleFriendsDetailBottomView *bottomView;

@end
@implementation ZYCCircleFriendsColletionCell
- (void)setModel:(ZYCCycleFriendDetailModel *)model{
    _model = model;
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/zd-system-service%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"sdfz_url"],model.filePath]];
    [self.imageView sd_setImageWithURL:url];
    self.bottomView.content = model.content;

}

- (void)setUploadUserName:(NSString *)uploadUserName{
    _uploadUserName = uploadUserName;
    self.bottomView.uploadUserName = uploadUserName;
}



- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap:)];
        tap.numberOfTouchesRequired = 1;
        tap.numberOfTapsRequired = 1;
        [self addSubview:self.imageView];
        [self addSubview:self.bottomView];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];
        [self addGestureRecognizer:tap];
        [self bringSubviewToFront:self.bottomView];
    }
    return self;
}

- (ZYCCycleFriendsDetailBottomView *)bottomView {
    if (!_bottomView) {
        _bottomView = [[ZYCCycleFriendsDetailBottomView alloc] init];
    }
    return _bottomView;
}

- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _imageView;
}

- (void)clickTap:(UIGestureRecognizer *)tap{
    if ([self.bottomView isHidden] == YES) {
        [self.bottomView show];
    }else{
        [self.bottomView disMiss];
    }
}

@end
